<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:f="http://java.sun.com/jsf/core"> 

<h:head>
<title>Cadastro de usuarios</title>
</h:head> 
<h:body>
	<h1>Cadastro de Usuario</h1>
	<h:form id="cadastro">
	<h:messages/>
		<h:inputHidden value="#{usuarioBean.usuario.codigo}"/>
		<h:inputHidden value="#{usuarioBean.usuario.ativo}"/>
		<h:inputHidden value="#{usuarioBean.destinoSalvar}" />
		<h:panelGrid columns="2">
			<h:outputLabel value="Nome:" for="nome"/>
			<h:inputText id="nome" label="Nome" value="#{usuarioBean.usuario.nome}" size="30" maxlength="30" required="true" requiredMessage="Você não tem nome?">
				<f:validateLength minimum="10" maximum="30"/>
			</h:inputText>
				
			<h:outputLabel value="Data Nascimento:" for="data"/>
			<h:inputText id="data" label="Data Nascimento" value="#{usuarioBean.usuario.nascimento}" size="10" maxlength="10" required="true">
				<f:convertDateTime dateStyle="medium" pattern="dd/MM/yyyy" locale="pt_BR" timeZone="GMT-3" />
			</h:inputText>
			
			<h:outputLabel value="e-Mail:" for="email"/>
			<h:panelGroup>
				<h:inputText id="email" 
					label="e-Mail" 
					value="#{usuarioBean.usuario.email}" 
					size="50" maxlength="50" required="true" 
					validatorMessage="e-Mail inválido">
					<f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+"/>
				</h:inputText>
				<h:message for="email"/> 
			</h:panelGroup>
			
			<h:outputLabel value="Login:" for="login"/>
			<h:inputText id="login" 
			             label="Login" 
			             value="#{usuarioBean.usuario.login}" 
			             size="15" maxlength="15" required="true"
			             validatorMessage="Login deve ter no mínimo 5 e no máximo 15 caracters e só pode ter os simbolos '.' e '_'.">
				<f:validateRegex pattern="([a-z]|[0-9]|[.]|[_]){5,15}"/>
			</h:inputText>
	
			<h:outputLabel value="Senha:" for="senha"/>
			<h:inputSecret id="senha" label="Senha" value="#{usuarioBean.usuario.senha}" size="10" maxlength="10" required="true" redisplay="true"/>
				
			<h:outputLabel value="Confirmar Senha:" for="confirmarsenha"/>
			<h:inputSecret id="confirmarsenha" label="Confirmar Senha" value="#{usuarioBean.confirmarSenha}" size="10" maxlength="10" required="true" redisplay="true"/>
		</h:panelGrid>
		<h:commandButton action="#{usuarioBean.salvar}" value="Salvar"/>
	</h:form>
</h:body> 
</html>
